package com.ucode.application.form.sys;

import java.io.Serializable;
import java.util.List;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import org.hibernate.validator.constraints.Length;

import com.ucode.springboot.starter.web.validator.annotation.CheckMember;
import com.ucode.springboot.starter.web.validator.group.AddGroup;
import com.ucode.springboot.starter.web.validator.group.UpdateGroup;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 系统用户表单实体
 * @author: liliang
 * @date: 2019年12月16日 下午8:31:49
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="系统用户")
public class UserForm implements Serializable{

    private static final long serialVersionUID = -141507115966837140L;
    
    /**
     * 用户名
     */
    @ApiModelProperty(value = "用户名,为空时手机号就是用户名",required=true)
    @Length(max=50,message = "用户名最长50字符", groups = {AddGroup.class})
    private String username;
    /**
     * 密码
     */
    @ApiModelProperty(value = "密码,注册必填,更新非必填")
    //最短6位，最长16位 {6,16},必须包含1位数字2位小写字母2位大写字母1位特殊字符:  ^.*(?=.{6,16})(?=.*\\d)(?=.*[A-Z]{2,})(?=.*[a-z]{2,})(?=.*[!@#$%^&*?\\(\\)]).*$
    //最短6位，最长16位 {6,16},可以包含大小写字母、数字、下划线 和减号 
    @NotBlank(message = "密码不能为空", groups = {AddGroup.class})
    @Pattern(regexp = "^[\\w_-]{6,16}$",message = "密码长度6-16,可由大小写字母、数字、下划线 和减号组成", groups = {AddGroup.class})
    private String password;
    /**
     * 真实姓名
     */
    @ApiModelProperty(value = "真实姓名",required=true)
    @NotBlank(message = "真实姓名不能为空", groups = {AddGroup.class,UpdateGroup.class})
    @Length(min=1,max=50,message = "真实姓名长度1-50字符", groups = {AddGroup.class,UpdateGroup.class})
    private String realname;
    /**
     * 头像
     */
    @ApiModelProperty(value = "头像地址")
    @Length(max=200,message = "头像地址最大长度200字符", groups = {AddGroup.class,UpdateGroup.class})
    private String headImg;
    /**
     * 手机号
     */
    @ApiModelProperty(value = "手机号",required=true)
    @NotBlank(message = "手机号不能为空", groups = {AddGroup.class,UpdateGroup.class})
    @Pattern(regexp = "^(1[3-9])\\d{9}$",message = "手机号码格式错误", groups = {AddGroup.class,UpdateGroup.class})
    private String mobile;
    /**
     * 邮箱
     */
    @ApiModelProperty(value = "邮箱",required=true)
    @NotBlank(message = "邮箱不能为空", groups = {AddGroup.class,UpdateGroup.class})
    @Email(message = "邮箱格式不正确", groups = {AddGroup.class,UpdateGroup.class})
    private String email;
    /**
     * 员工编号
     */
    @ApiModelProperty(value = "员工编号",required=true)
    @NotBlank(message = "员工编号不能为空", groups = {AddGroup.class,UpdateGroup.class})
    @Length(min=1,max=20,message = "员工编号长度1-20字符", groups = {AddGroup.class,UpdateGroup.class})
    private String num;
    /**
     * 性别：0 未知 1 男 2 女 
     */
    @ApiModelProperty(value = "性别:0未知1男2女",required=true,example="0",dataType="Integer")
    @NotNull(message = "员工性别不能为空", groups = {AddGroup.class,UpdateGroup.class})
    @CheckMember(value={"0","1","2"},message="员工性别非法", groups = {AddGroup.class,UpdateGroup.class})
    private Integer sex;
    /**
     * 状态：0禁用,1正常,2未激活,3离职
     */
    @ApiModelProperty(value = "状态：0禁用,1正常",required=true,example="2")
    @NotNull(message = "员工状态不能为空", groups = {AddGroup.class,UpdateGroup.class})
    @CheckMember(value={"0","1"},message="员工状态非法", groups = {AddGroup.class,UpdateGroup.class})
    private Integer statuz;
    /**
     * 部门Id
     */
    @ApiModelProperty(value = "部门Id",required=true)
    @NotNull(message = "部门不能为空", groups = {AddGroup.class,UpdateGroup.class})
    private Long deptId;
    /**
     * 职位
     */
    @ApiModelProperty(value = "职务")
    @Length(max=50,message = "职务最大长度50字符", groups = {AddGroup.class,UpdateGroup.class})
    private String job;
    /**
     * 直属上级
     */
    @ApiModelProperty(value = "直属上级",required=true)
    @NotNull(message = "直属上级不能为空", groups = {AddGroup.class,UpdateGroup.class})
    private Long parentId;
    
    @ApiModelProperty(value = "角色Ids",required=false)
    private List<Long> roleIds;
    
}
